Skip to content

Don't forward the caller's headers on a redirect to another origin - #225

Merged
mbarta merged 1 commit into
mainfrom
redirect-caller-headers
Nov 5, 2026
Merged

mbarta merged 1 commit into
mainfrom
redirect-caller-headers

Conversation

@mbarta

@mbarta mbarta commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

OkHttp forwards a request's headers to the redirect target and only drops Authorization when the origin changes. Apps can pass any header through the path configuration's httpHeaders, so the shared HotwireHttpClient now removes the caller's headers on a redirect hop to a different origin than the original request.

  • A network interceptor does this, so it sees every hop.
  • Cookies that WebViewCookieJar loads for the hop are the destination's own, so they stay.
  • Same-origin redirects keep all of the caller's headers.

The tests cover a cross-origin hop, a same-origin hop, a chain that continues on the other origin, and the destination's own cookies. A second test checks that the shared client installs the interceptor.

🤖 Generated with Claude Code

OkHttp forwards a request's headers to the redirect target and only drops
Authorization when the origin changes. Apps can pass any header through the
path configuration's httpHeaders, so a network interceptor on the shared
client now removes the caller's headers on a hop to a different origin than
the original request. Cookies the cookie jar loads for that hop are the
destination's own, so they stay.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mbarta
mbarta merged commit 56e02c8 into main Nov 5, 2026
1 check passed
@mbarta
mbarta deleted the redirect-caller-headers branch November 5, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant